<!-- templates/register.html -->
{% extends "base.html" %}

{% block title %}用户注册{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h3 class="card-title mb-0">注册新账户</h3>
                </div>
                <div class="card-body">
                    <form method="POST" action="{{ url_for('register') }}">
                        {{ form.hidden_tag() }}
                        
                        <!-- 用户名 -->
                        <div class="form-group">
                            {{ form.username.label(class="form-label") }}
                            {% if form.username.errors %}
                                {{ form.username(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.username.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.username(class="form-control", placeholder="请设置用户名（4-64字符）") }}
                            {% endif %}
                        </div>
                        
                        <!-- 邮箱 -->
                        <div class="form-group">
                            {{ form.email.label(class="form-label") }}
                            {% if form.email.errors %}
                                {{ form.email(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.email.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.email(class="form-control", placeholder="请输入有效邮箱") }}
                            {% endif %}
                        </div>
                        
                        <!-- 密码 -->
                        <div class="form-group">
                            {{ form.password.label(class="form-label") }}
                            {% if form.password.errors %}
                                {{ form.password(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.password.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.password(class="form-control", placeholder="请设置密码（至少6位）") }}
                            {% endif %}
                        </div>
                        
                        <!-- 确认密码 -->
                        <div class="form-group">
                            {{ form.password2.label(class="form-label") }}
                            {% if form.password2.errors %}
                                {{ form.password2(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.password2.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.password2(class="form-control", placeholder="请再次输入密码") }}
                            {% endif %}
                        </div>
                        
                        <!-- 提交按钮 -->
                        <div class="form-group text-center">
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fas fa-user-plus me-2"></i>注册账户
                            </button>
                        </div>
                    </form>
                </div>
                <div class="card-footer text-center">
                    <small class="text-muted">
                        已有账户？<a href="{{ url_for('login') }}" class="text-primary">立即登录</a>
                    </small>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}